﻿#ifndef __ENEMY_H_
#define __ENEMY_H_

#include<QTimer>
#include"EnemyPlaneProperty.h"
class EnemyPlane;
class WeaponBank;
//敌方飞机组
class Enemy :public Articles
{
public:
    Enemy() ;
    ~Enemy();
    //自动放飞机初始化
    void init();
    void update();
    void draw(QPainter* painter);
    //添加一个飞机
    void addPlane(const QPoint& point,const EnemyPlaneProperty::Type type= EnemyPlaneProperty::Type::small);
    void addPlane(const int x, const int y,const EnemyPlaneProperty::Type type = EnemyPlaneProperty::Type::small);
    //设置自动飞机的循环出现时间范围
    void setTimerPlane(const int MinTime, const int MaxTime, const EnemyPlaneProperty::Type type = EnemyPlaneProperty::Type::small);
    //设置自动飞机的步长
    void setSteplenPlane(const int Steplen, const EnemyPlaneProperty::Type type = EnemyPlaneProperty::Type::small);
    //设置自动飞机的血量
    void setHpPlane(const int hp, const EnemyPlaneProperty::Type type = EnemyPlaneProperty::Type::small);
    //设置自动子弹
    void setAutoBullet(bool flag, int time = -1, const EnemyPlaneProperty::Type type = EnemyPlaneProperty::Type::small);
    //设置出场的飞机种类EnemyPlaneProperty::Type
    void setPlaneType(const int type);
    //设置窗口,限制范围用,设置后程序才能放的出敌机
    void setWindow(const QRect& rect);
    //设置碰撞器
    void setCollider(const QRect& collider);
    //开启血条显示-间距和方向
    void startBlood(int space, const Plane::Direction& dir, const EnemyPlaneProperty::Type type);
    //开启全部血条
    void startBlood(int space, const Plane::Direction& dir);
    //关闭血条显示
    void closeBlood(const EnemyPlaneProperty::Type type);
    //关闭全部血条
    void closeBlood();
    //开始放飞机
    void startAuto();
    //关闭放飞机
    void closeAuto();
    //创建敌机武器库
    void creatorWeaponBank();
    //返回武器库的指针
    WeaponBank* getWeaponBank();
    //获取敌方飞机组
    QVector<EnemyPlane*>& getEnemyPlane();
    //设置暂停
    void setPause(bool flag);
private:
    //自动放飞机
    void AutoPlane();
    //设置血条状态
    void setBlood(EnemyPlaneProperty&plan, bool flagBlood,int space, const Plane::Direction& dir);
private:
    QVector<EnemyPlane*> m_Enemy;//敌方飞机组
    QMap<EnemyPlaneProperty::Type, EnemyPlaneProperty>m_Property;//敌机属性
    int m_PlaneType=7;//出场飞机种类,默认全部启用
    bool flag = true;//AutoPlane();
    WeaponBank* m_WeaponBank = nullptr;//武器库
};

#endif 